﻿using Nemerle.Text;
using Nemerle.Utility;
using Nemerle.Data;

using System;
using System.Collections.Generic;
using System.Console;
using System.Linq;

using FsCheck.Fluent;

namespace QCTests
{
  public module TestSlices
  {
    public Run() : void
    {
      Spec.ForAny(xs : array[int] => xs.Slice(0, xs.MaxIndex()).SequenceEqual(xs))
        .QuickCheck("SliceId");
        
      Spec.ForAny(xs : array[int] => xs.Slice(1, xs.MaxIndex()).SequenceEqual(xs.Tail()))
        .When(xs => xs.Length > 0)
        .QuickCheck("SliceTail");
        
      Spec.ForAny(xs : array[int] => xs.Slice(0, xs.MaxIndex() - 1).SequenceEqual(xs.Init()))
        .When(xs => xs.Length > 0)
        .QuickCheck("SliceInit");
        
      Spec.ForAny((xs : array[int], ys : array[int]) => xs.Slice(0, xs.MaxIndex()).Concatenate(ys.Slice(0, ys.MaxIndex()))
        .SequenceEqual(xs.Concatenate(ys)))
        .QuickCheck("SliceConcatenate");
        
      Spec.ForAny(xs : array[int] => xs.Slice(0, xs.MaxIndex()).Force().SequenceEqual(xs))
        .QuickCheck("SliceForceId");
        
      Spec.ForAny((xs : array[int], ys : array[int]) => xs.Slice(0, xs.MaxIndex())
        .Concatenate(ys.Slice(0, ys.MaxIndex())).Force()
        .SequenceEqual(xs.Concatenate(ys)))
        .QuickCheck("SliceForceConcatenate");
    }
  }
}
